﻿function searchFriend() {
    keyword = $("#inputNameSearch").val()
    location.href = "/UserManagement/MyFriendsList/1/" + keyword;
}

function gotoFriendPage(page) {
    location.href = "/UserManagement/MyFriendsList/" + page + "/" + keyword;
}

function jumpToPage(page) {
    location.href = "/UserManagement/MyFriendsList/" + page + "/" + keyword;
}

function deleteFriend(id, page) {
    $.msgbox("Are you sure that you want to permanently delete the selected element?", {
        type: "info",
        buttons: [
          { type: "submit", value: "Yes" },
          { type: "submit", value: "No" },
        ]
    }, function (result) {
        if (result == "Yes") {
            $.ajax(
                {
                    type: "POST",
                    url: "/UserManagement/DeleteFriend",
                    data: { username: id },
                    success: function (result) {
                        if (result.Result) {
                            $.msgbox(result.Message, { type: "info" });
                            window.location.href = "/UserManagement/MyFriendsList/" + page + "/" + keyword;
                        }
                        else {
                            $.msgbox(result.Message, { type: "error" });
                        }
                    }
                });
        }
    });
}